package mao.thinkinjava.io;

import java.io.File;
import java.io.IOException;

public class TestMakeDirectories {
    public static void main(String[] args) throws IOException {
        String filePath = "C:\\Users\\xk1008\\IdeaProjects\\untitled\\src\\com\\mao\\thinkinjava\\io\\Test.java";
        File file = new File(filePath);
        //C:\Users\xk1008\AppData\Local\Temp\java2676523890625891891.java
        //所以这里只是前缀，并不是真正要创建的文件的名字。
        File java = File.createTempFile("java", ".java");
        String canonicalPath = java.getCanonicalPath();
        System.out.println(canonicalPath);
        if (file.exists()){
            System.out.println(file.canRead());
            System.out.println(file.getParent());
        }else {
           // file.mkdirs();
           // file.mkdir();
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
                System.out.println(e.getMessage());
            }
            System.out.println("create file\n");
        }
    }
}
